﻿<Window x:Class="DataBinding.RadioButtonList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="RadioButtonList" Height="300" Width="300"
    >
  <Window.Resources>
    <Style x:Key="RadioButtonListStyle" TargetType="{x:Type ListBox}">

      <Setter Property="ItemContainerStyle">
        <Setter.Value>
          <Style TargetType="{x:Type ListBoxItem}" >
            <Setter Property="Margin" Value="2" />
            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                  
                    <RadioButton 
											Focusable="False"
											IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"
											>
                      <ContentPresenter></ContentPresenter>
                    </RadioButton>
                  
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Style>
        </Setter.Value>
      </Setter>
    </Style>
  </Window.Resources>
  
    <Grid Margin="8">
      <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition Height="Auto"></RowDefinition>
      </Grid.RowDefinitions>
      <ListBox Style="{StaticResource RadioButtonListStyle}" Name="lstProducts"
               DisplayMemberPath="ModelName">
      </ListBox>
      <Button Grid.Row="1" Margin="0,5,0,0" Click="cmdGetSelectedItem">Get Selected Item</Button>
    </Grid>
</Window>
